package com.activiti.tool;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.TaskService;
import org.activiti.engine.task.Task;

import java.util.List;

/**
 * 代办任务查询
 *
 * @author ldanniel
 */
public class TaskQuery {
    public static void main(String[] args) {
        //创建
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        //获取任务相关的Service
        TaskService taskService = processEngine.getTaskService();
        //根据流程key和任务的负责人 查询待办任务
        List<Task> list = taskService.createTaskQuery()
                //流程key
                .processDefinitionKey("myEvection")
                ////流程负责人
                .taskAssignee("rose")
                .list();
        for (Task task : list) {
            System.out.println("流程实例Id = " + task.getProcessInstanceId());
            System.out.println("任务Id = " + task.getId());
            System.out.println("任务负责人 = " + task.getAssignee());
            System.out.println("任务名称 = " + task.getName());
        }
    }
}
